package com.sunday.common.sharding.sphere.jdbc.study.base.sync.interrupt;

/**
 * @Description:
 * @Author: zsy
 * @Create: 2023/4/4 15:42
 */
public class SynchronizeAndReentrant2 {

    int i = 1;

    /**
     * 相同方法，synchronized是可重入的
     */
    public static void main(String[] args) throws Exception {
        SynchronizeAndReentrant2 synchronizeAndReentrant = new SynchronizeAndReentrant2();
        synchronizeAndReentrant.test1();
    }
    public synchronized void test1(){

        System.out.println(" test1 method is called " + i++ + "st time..." );
        while(i < 5) {
            test1();
        }
    }

}
